package com.example.LinuxSpringBoot.Controller;

import com.example.LinuxSpringBoot.domain.User;
import com.example.LinuxSpringBoot.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController//返回json字符串
@Slf4j//日志打印
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;//这里注入接口，实际使用的是实现类

    @GetMapping("/")
//    @ResponseBody
    public List<User> getAllUsers() {
        List<User> users = userService.getAllUsers();
        log.info("\n查询结果：{}\n", users);
        return users;
    }


}
